package com.moon.robot.service;


import com.forte.qqrobot.anno.depend.Beans;
import com.forte.qqrobot.anno.depend.Depend;
import com.forte.qqrobot.sender.MsgSender;
import com.moon.robot.mapper.GroupMapper;
import com.moon.robot.mapper.MessageMapper;
import com.moon.robot.pojo.Reply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import java.util.List;

@Beans
@Component
public class GroupServiceImpl implements GroupService {

    @Autowired
    MessageMapper messageMapper;


    @Autowired
    GroupMapper groupMapper;


    @Override
    public int insertMsg(Reply reply) {
        System.out.println("开始加入数据库");
        return messageMapper.insertNewMsg(reply);
    }




    /*模糊查询*/

    /*精确查询*/
    @Override
    public List<Reply> exactSelectMsg(String msg) {
        return messageMapper.exactSelectMsg(msg);
    }

    @Override
    public List<Reply> SelectAllVague() {
        return messageMapper.SelectAllVague();
    }

    @Override
    public String selectAnswerById(Integer id) {

        return messageMapper.selectAnswerById(id);
    }

    @Override
    public List<Reply> selMsgByKey(String s) {

        return messageMapper.selMsgByKey(s);
    }

    @Override
    public Integer delMsgByID(Integer id) {

        return messageMapper.delMsgByID(id);
    }

    @Override
    public List<String> findAllGroup() {
        return groupMapper.findAllGroup();
    }

    @Override
    public Integer openRobot(String group) {
        return groupMapper.openRobot(group);
    }

    @Override
    public Integer closeRobot(String group) {
        return groupMapper.closeRobot(group);
    }

    @Override
    public boolean selectEmoji(String url) {
        List<String> urlList = messageMapper.selectEmoji(url);
        if (urlList != null && urlList.size() > 0) {
            return true;
        }
        return false;

    }

    @Override
    public Integer addEmoji(String url) {
        return messageMapper.addEmoji(url);
    }

    @Override
    public Integer publishNotice(String qqgroup, List<String> list, MsgSender sender, String title) {

        String text="";

        for (String i:list){
            text=text+i+"\n";
        }
        sender.SENDER.sendGroupNotice(qqgroup,"科技更新"+title,text);





        return null;
    }


}
